<template>
  <div class="container">
    <div class="row" v-for="o in list.length/2" :key="o">
      <div class="row-item">
        <div class="spanIndex">{{filterIndex(o)}}</div>
        <div class="img">
          <img v-lazy="list[o-1].picUrl" width="40" height="40" />
        </div>
        <div class="desc">
          <p class="songname">{{list[o-1].song.name}}</p>
          <p class="author">{{list[o-1].song.artists | authorfilter}}</p>
        </div>
      </div>

      <div class="row-item">
        <div class="spanIndex">{{filterIndex(o+5)}}</div>
        <div class="img">
          <img v-lazy="list[o+4].picUrl" width="40" height="40" />
        </div>
        <div class="desc">
          <p class="songname">{{list[o+4].song.name}}</p>
          <p class="author">{{list[o+4].song.artists | authorfilter}}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['songlist'],
  methods: {
    filterIndex (index) {
      if (index > 9) {
        return index
      }
      return `0${index}`
    }
  }, computed: {
    list () {
      return this.songlist
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  height: auto;

  .row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    height: 60px;
    border: 1px solid #eee;

    &:nth-of-type(2n) {
      background-color: #fafafe;
    }

    &:nth-of-type(n):not(:last-of-type) {
      border-bottom: 0;
    }

    .row-item {
      height: 100%;
      box-sizing: border-box;
      width: 50%;
      text-align: left;
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      &:hover {
        background-color: #cdcccf;
      }

      &:nth-child(2n + 1) {
        border-right: 1px solid #ddd;
      }

      .spanIndex {
        width: 40px;
        line-height: 60px;
        text-align: center;
      }

      .img {
        flex-basis: 40px;
        padding: 10px 0px;
        text-align: center;
      }

      .desc {
        flex: 6 1 auto;
        font-size: 14px;
        padding: 12px 0 0 8px;

        p {
          padding: 0;
          margin: 0;
          margin-bottom: 10px;
        }
        .songname {
          font-size: 14px;
          color: #333;
        }

        .author {
          font-size: 12px;
          color: #999;
        }
      }
    }
  }
}
</style>